package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.ProjectTypeRequest;
import cn.stylefeng.guns.modular.business.service.ProjectTypeService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 控制器
 *
 * @author zhangyaowen
 * @date 2021/10/12 15:07
 */
@RestController
@ApiResource(name = "工程科技controller")
public class ProjectTypeController {

    @Resource
    private ProjectTypeService projectTypeService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @PostResource(name = "添加", path = "/projectType/add")
    public ResponseData add(@RequestBody @Validated(ProjectTypeRequest.add.class) ProjectTypeRequest projectTypeRequest) {
        projectTypeService.add(projectTypeRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @PostResource(name = "删除", path = "/projectType/delete")
    public ResponseData delete(@RequestBody @Validated(ProjectTypeRequest.delete.class) ProjectTypeRequest projectTypeRequest) {
        projectTypeService.del(projectTypeRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @PostResource(name = "编辑", path = "/projectType/edit")
    public ResponseData edit(@RequestBody @Validated(ProjectTypeRequest.edit.class) ProjectTypeRequest projectTypeRequest) {
        projectTypeService.edit(projectTypeRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @GetResource(name = "查看详情", path = "/projectType/detail")
    public ResponseData detail(@Validated(ProjectTypeRequest.detail.class) ProjectTypeRequest projectTypeRequest) {
        return new SuccessResponseData(projectTypeService.detail(projectTypeRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @GetResource(name = "获取列表", path = "/projectType/list")
    public ResponseData list(ProjectTypeRequest projectTypeRequest) {
        return new SuccessResponseData(projectTypeService.findList(projectTypeRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/14 16:07
     */
    @GetResource(name = "分页查询", path = "/projectType/page")
    public ResponseData page(String value) {
        ProjectTypeRequest projectTypeRequest = new ProjectTypeRequest();
        projectTypeRequest.setHydraulicType(value);
        return new SuccessResponseData(projectTypeService.findPage(projectTypeRequest));
    }

    /**
     *
     * @return
     * @date 2021/10/14 16:07
     */
    @GetResource(path ="/projectType/findProjectType")
    public ResponseData findProjectType() {
        return new SuccessResponseData(projectTypeService.findProjectType());
    }

    /**
     *
     * @return
     * @date 2021/10/14 16:07
     */
    @GetResource(path ="/projectType/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(projectTypeService.toReview(id));
    }
}